package com.yunji.product.dao.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yunji.common.base.BaseDaoImpl;
import com.yunji.common.utils.bean.BeanUtils;
import com.yunji.product.bo.AttrListQueryBO;
import com.yunji.product.dao.IProductAttrDao;
import com.yunji.product.domain.AttrDO;
import com.yunji.product.mapper.ProductAttrMapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ProductAttrDaoImpl extends BaseDaoImpl<ProductAttrMapper, AttrDO> implements IProductAttrDao {
    @Override
    public List<AttrDO> search(AttrListQueryBO bo) {
        return list(new LambdaQueryWrapper<AttrDO>()
                .eq(BeanUtils.isNotNull(bo.getAttrId()), AttrDO::getAttrId, bo.getAttrId())
                .like(BeanUtils.isNotNull(bo.getAttrName()), AttrDO::getAttrName, bo.getAttrName())
                .orderByAsc(AttrDO::getSort));
    }
}
